home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’95 / CyberProcDoggie / Source Code / Woof / Woof_Real / WoofURL.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-24  |  1.1 KB  |  52 lines  |  [TEXT/MPS ]

  1. #include "WoofURL.h"
  2.  
  3. void ParseWoofURL(char* url, char **hostName, unsigned short *hostNameLen, 
  4.                     char **procName, unsigned short *procNameLen)
  5. {
  6.     unsigned short i;
  7.     unsigned short startPos;
  8.     
  9.     *hostName = nil;
  10.     *hostNameLen = 0;
  11.     *procName = nil;
  12.     *procNameLen = 0;
  13.     
  14.     i = 0;
  15.     while ((url[i] != ':') && (url[i] != '\0'))
  16.         ++i;
  17.     
  18.     if ((url[i] == ':') && (url[i+1] == '/') && (url[i+2] == '/'))
  19.     {
  20.         i += 3;   // skip over '://'
  21.         
  22.         // find the first string following '//', either hostname or procname
  23.         startPos = i;
  24.         while ((url[i] != '/') && (url[i] != '\0'))
  25.             ++i;
  26.         
  27.         // if stopped at a '/' and more string follows then string is a hostname
  28.         // and the procname follows
  29.         // otherwise the string was a procname and there's no hostname
  30.         if ((url[i] == '/') && (url[i+1] != '\0'))
  31.         {
  32.             *hostName = url + startPos;
  33.             *hostNameLen = i - startPos;
  34.             
  35.             // now find the proc name
  36.             ++i;     // skip over '/'
  37.             
  38.             startPos = i;
  39.             while (url[i] != '\0')
  40.                 ++i;
  41.             *procName = url + startPos;
  42.             *procNameLen = i - startPos;
  43.         }
  44.         else
  45.         {
  46.             *procName = url + startPos;
  47.             *procNameLen = i - startPos;
  48.         }
  49.     }
  50. }
  51.  
  52.